/**
 * Created by admin on 2018/11/16.
 */
const squel = require("squel");

const fields = {
	id: "id",
	mobile: "mobile",
	scoreInfo: "scoreInfo",
	score: "score",
	queryTimes: "queryTimes",

	"DATE_FORMAT(gmtCreate, '%Y-%m-%d %T')": "gmtCreate",
	"DATE_FORMAT(gmtUpdate, '%Y-%m-%d %T')": "gmtUpdate"
};


const scoreInfoDao = {
	insert: (scoreInfo) => squel.insert().into("scoreInfo").setFields(scoreInfo)
    .toString(),

	updateQueryTimes: (mobile) => squel.update().table("scoreInfo").set("queryTimes=queryTimes+1")
  .where("mobile = ?", mobile)
  .toString(),

	update: (scoreInfo) => squel.update().table("scoreInfo").setFields(scoreInfo)
    .where("mobile = ?", scoreInfo.mobile)
    .toString(),

	select: (mobile) => squel.select().from("scoreInfo").fields(fields)
    .where("mobile = ?", mobile)
    .toString(),

};
module.exports = scoreInfoDao;